package com.zcb.qingshoudan.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zcb.qingshoudan.R;
import com.zcb.qingshoudan.entity.GatheringHistoryVoDetails;
import com.zcb.qingshoudan.utils.CircularImage;

import java.util.List;

/**
 * Created by ZCB on 2016/12/1.
 */

public class GatherHistoryAdapter extends RecyclerView.Adapter<GatherHistoryAdapter.ViewHoler> {
    private List<GatheringHistoryVoDetails> gatheringHistoryVoDetailses;

    public GatherHistoryAdapter(List<GatheringHistoryVoDetails> gatheringHistoryVoDetailses) {
        this.gatheringHistoryVoDetailses = gatheringHistoryVoDetailses;
    }


    @Override
    public ViewHoler onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_gathering_history,parent,false);
        ViewHoler vh=new ViewHoler(view);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHoler holder, int position) {
        holder.tvName.setText(gatheringHistoryVoDetailses.get(position).getGoods_name());
        holder.tvTime.setText(gatheringHistoryVoDetailses.get(position).getAdd_time().substring(10,16));
        holder.tvDate.setText(gatheringHistoryVoDetailses.get(position).getAdd_time().substring(0,10));
        holder.tvMoney.setText(gatheringHistoryVoDetailses.get(position).getGoods_price());
    }

    @Override
    public int getItemCount() {
        return this.gatheringHistoryVoDetailses.size();
    }

    public class ViewHoler extends RecyclerView.ViewHolder{

        public ViewHoler(View itemView) {
            super(itemView);
            this.circularImage= (CircularImage) itemView.findViewById(R.id.gathering_history_icon);
            this.tvName= (TextView) itemView.findViewById(R.id.gathering_history_name);
            this.tvTime= (TextView) itemView.findViewById(R.id.gathering_history_time);
            this.tvDate= (TextView) itemView.findViewById(R.id.gathering_history_date);
            this.tvMoney= (TextView) itemView.findViewById(R.id.gathering_history_money);
        }
        public CircularImage circularImage;
        public TextView tvName;
        public TextView tvTime;
        public TextView tvDate;
        public TextView tvMoney;

    }
}
